﻿@{
    ViewBag.Title = "网站管理平台_登录";
}

@section HeadContent{
    <script type="text/javascript">
//        Ext.onReady(function () {
//            var ckName = Ext.util.Cookies.get("loginuser");
//            console.log(Ext.getCmp("App.txtUserName"));
//        });
    </script>
}

<h1>网站管理平台</h1>


@(Html.X().Window()
    .Title("登录窗口")
    .Width(350)
    .DefaultButton("BtnSubmit")
    .ButtonAlign(Alignment.Left)
    .Icon(Icon.Lock)
    .Layout("fit")
    .Closable(false)
    .Draggable(false)
    .Resizable(false)
    .Modal(true)
    .Items(Html.X().FormPanel()
        .DefaultAnchor("100%")
        .Layout("form")
        .Frame(true)
        .Items(
            Html.X().TextField()
                .ID("txtUserName")
                .IDMode(IDMode.Explicit)
                .FieldLabel("用户名")
                .AllowBlank(false)
                .BlankText("请输入用户名")
                .Listeners(ls =>
                {
                    ls.AfterRender.Handler = "var ckName = Ext.util.Cookies.get('loginuser'); #{txtUserName}.setValue(ckName);";
                }),
            Html.X().TextField()
                .ID("txtPassword")
                .IDMode(IDMode.Explicit)
                .FieldLabel("密码")
                .InputType(Ext.Net.InputType.Password)
                .AllowBlank(false)

        )
        .Buttons(Html.X().Button()
            .ID("btnSubmit")
            .Text("登录")
            .Icon(Icon.Accept)
            .DirectEvents(de =>
            {
                de.Click.Action = "VerifyUser";
                de.Click.EventMask.Msg = "正在验证，请稍候...";
                de.Click.EventMask.ShowMask = true;
                de.Click.EventMask.MinDelay = 500;
                de.Click.Success = "window.location='/';";
                de.Click.Failure = "ext.net.comjs.onSubmitFailure";

            })
            .Listeners(ls =>
            {
                ls.Click.Handler = "if (!#{txtUserName}.validate() || !#{txtPassword}.validate()) { " +
                                "Ext.Msg.show({title:'错误', msg:'请输入用户名和密码。', buttons:Ext.Msg.OK, icon:Ext.Msg.ERROR, modal:true}); return false; }";
            })
        )
    )
)